﻿using System;
using DeSleeper.Client.Framework;
using DeSleeper.Library;
using DeSleeper.Client.Properties;

namespace DeSleeper.Client.SystemConfig
{
	public class EnableWakeOnLanCommand : AsyncCommand
	{
		public override string Text
		{
			get { return Resources.EnableWakeOnLanCommandName; }
		}

		/// <exception cref="ArgumentException">
		/// <see cref="EnableWakeOnLanCommand"/> requires <see cref="WakeOnLanNetworkInterface"/>
		/// </exception>
		protected override void OnExecute(object parameter)
		{
			var adapter = parameter as WakeOnLanNetworkInterface;
			if (adapter == null)
				throw new ArgumentException(Resources.ErrorRequiresNetworkInterface, "parameter");

			if (adapter.WakeOnLanConfiguration.WakeOnLanEnabled.IsEnabled)
                adapter.DisableWakeOnLan();
			else
				adapter.EnableWakeOnLan();
		}
	}
}